package com.etone.smartAudit.enums;

import com.etone.smartAudit.domain.ItemSource;
import lombok.Getter;

/**
 * @author: sovy
 * @date: 2020/11/12
 * @description:
 */
public enum AccountType {
    OPERATE_SYSTEM("操作系统"),
    MYSQL("MySQL"),
    FTP("FTP"),
    ORACLE("Oracle"),
    HADOOP("Hadoop"),
    GREENPLUM("Greenplum");

    @Getter
    private String value;

    AccountType(String value) {
        this.value = value;
    }

    public static AccountType parseFromItemSource(ItemSource itemSource) {
        if (itemSource == null) {
            return null;
        }
        if (itemSource.getType().equals(ItemSourceType.SPACE)) {
            if (AccountType.FTP.name().equals(itemSource.getName().toUpperCase())) {
                return FTP;
            } else {
                return OPERATE_SYSTEM;
            }
        }
        if (itemSource.getType().equals(ItemSourceType.DATABASE)) {
            return AccountType.valueOf(itemSource.getName().toUpperCase());
        }
        return null;

    }


}
